import { name } from '../../package.json'
const isDev = import.meta.env.DEV
const domain = isDev ? '/api' : `${location.protocol}//${location.host}`
const defaultHost = import.meta.env.VITE_API_URL
const tempUrl = isDev ? defaultHost : domain
const realHost = tempUrl.substr(-1) === '/' ? tempUrl.slice(0, -1) : tempUrl
const webHomePage = isDev ? '' : `${window.location.origin}/${name}`
const loginURL = isDev
    ? `${realHost}/cas/login?service=${realHost}/simple-user-center-server/userCenter/auth/authUser`
    : `${realHost}/cas/login?service=${realHost}/simple-user-center-server/userCenter/auth/authUser?redirectUrl=${encodeURIComponent(webHomePage)}`

// 暴露配置
export default {
    // 系统标题
    systemTitle: '杭州 • 生态智卫',
    // 是否是开发环境
    isDev,
    // 接口请求地址
    domain,
    // 请求超时时间
    requestTimeOut: 60 * 1000,
    // public文件夹的根路径
    publicPath: import.meta.env.BASE_URL,
    // public下的image-assets文件夹的根路径
    publicImageAssets: `${import.meta.env.BASE_URL}image-assets/`,
    // 重定向-登陆-地址
    loginURL,
    // 系统菜单权限编码
    systemMenuCode: 'stzwPowerfulScreen',
    // 地图初始化配置
    mapInitOptions: {
        zoom: 9.35,
        minZoom: 4,
        maxZoom: 18,
        center: [119.67222667714213, 29.74605467153357],
        pitch: 45,
    },
    // 外部跳转地址
    outLinkDefaultRootPath: isDev
        ? defaultHost.substr(-1) === '/'
            ? defaultHost.slice(0, -1)
            : defaultHost
        : window.location.origin,
    // 微前端定义
    microAppList: [
        // 聚光app
        {
            name: 'fpi-app',
            url: isDev ? 'http://localhost:3089/' : `${window.location.origin}/hz-stzw-fpi/`,
            baseroute: '/fpi-child',
            iframe: true,
        },
        // 其它厂商
        {
            name: 'flight-monitoring',
            url: isDev ? 'http://localhost:3089/' : 'https://openmap.tech/monitoring/',
            baseroute: '/monitoring',
            iframe: true,
        },
    ],
    realHost,
}
